/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package business.histocloud.component;

/**
 *
 * @author thong
 */
public class ValueVector {

    public String word;
    public double[] value;
    boolean weightCalcule;
    double weight;

    public ValueVector(String word, int size) {
        this.word = word;
        value = new double[size];
        weightCalcule = false;
    }

    public void setValue(int pos, double v) {
        value[pos] = v;
    }

    public int getWeight() {
        if (!weightCalcule) {
            weight = 0;
            for (int i = 0; i < value.length; i++) {
                weight += value[i] * value[i];
            }
            weight = Math.sqrt(weight);
        }
        return (int)weight;
    }
}
